package com.xyz.xservice.config;

import com.hazelcast.config.ClasspathXmlConfig;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;


public class HazelcastConfiguration {

    protected Logger logger = LoggerFactory.getLogger(HazelcastConfiguration.class);

    @Bean("HazelcastInstance")
    public HazelcastInstance hazelcastInstance(){
        Config config = new ClasspathXmlConfig("hazelcast.xml");
        logger.info("HazelcastInstance配置 groupName:{},groupPwd:{}",config.getGroupConfig().getName(),config.getGroupConfig().getPassword());
        HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
        return hazelcastInstance;
    }
}
